package com.czy.fx.day1.stage;

import javafx.application.Application;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 * 窗口模态
 */
public class demo4 extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Stage stage1 = new Stage();
        stage1.setTitle("stage1");
        stage1.initStyle(StageStyle.DECORATED);

        Stage stage2 = new Stage();
        stage2.setTitle("stage2");
        stage2.initStyle(StageStyle.DECORATED);
        //stage2窗口属于stage1
        stage2.initOwner(stage1);
        /*定义一个模式窗口，该窗口阻止将事件传送到任何其他应用程序窗口*/
        //stage2.initModality(Modality.APPLICATION_MODAL);

        /*s2.initOwner(s1)简单理解就是s2是是s1的子窗口
            Modality.WINDOW_MODAL 就是建立在二级窗口上限制用户操作父窗口*/
        stage2.initModality(Modality.WINDOW_MODAL);

        Stage stage3 = new Stage();
        stage3.setTitle("stage3");
        stage3.initStyle(StageStyle.DECORATED);



        stage1.show();
        stage2.show();
        stage3.show();

    }
}